local R, L, P = unpack(select(2, ...)) --Import: Engine, Locales, ProfileDB, local
local M = R:GetModule("Misc")
local S = R:GetModule("Skins")

local function LoadFunc()
	local hcheck = CreateFrame("CheckButton", "HelmCheckBox", PaperDollFrame, "OptionsCheckButtonTemplate")
	hcheck:SetSize(20, 20)
	hcheck:SetPoint("TOPLEFT", CharacterHeadSlot, "BOTTOMRIGHT", 7, 10)
	hcheck:SetScript("OnClick", function () ShowHelm(not ShowingHelm()) end)
	hcheck:SetScript("OnEnter", function ()
		GameTooltip:SetOwner(hcheck, "ANCHOR_RIGHT")
		GameTooltip:SetText(SHOW_HELM)
	end)
	hcheck:SetScript("OnLeave", function () GameTooltip:Hide() end)
	hcheck:SetFrameStrata("HIGH")
	hcheck:SetHitRectInsets(0,0,0,0)
	S:ReskinCheck(hcheck)

	local ccheck = CreateFrame("CheckButton", "CloakCheckBox", PaperDollFrame, "OptionsCheckButtonTemplate")
	ccheck:SetSize(20, 20)
	ccheck:SetPoint("TOPLEFT", CharacterBackSlot, "BOTTOMRIGHT", 7, 14)
	ccheck:SetScript("OnClick", function () ShowCloak(not ShowingCloak()) end)
	ccheck:SetScript("OnEnter", function ()
		GameTooltip:SetOwner(ccheck, "ANCHOR_RIGHT")
		GameTooltip:SetText(SHOW_CLOAK)
	end)
	ccheck:SetScript("OnLeave", function () GameTooltip:Hide() end)
	ccheck:SetFrameStrata("HIGH")
	ccheck:SetHitRectInsets(0,0,0,0)
	S:ReskinCheck(ccheck)

	hooksecurefunc("ShowHelm", function(v) hcheck:SetChecked(v) end)
	hooksecurefunc("ShowCloak", function(v)	ccheck:SetChecked(v) end)

	local f = CreateFrame("Frame")
	f:RegisterEvent("PLAYER_ENTERING_WORLD")
	f:SetScript("OnEvent", function(self)
		self:UnregisterEvent("PLAYER_ENTERING_WORLD")
		hcheck:SetChecked(ShowingHelm())
		ccheck:SetChecked(ShowingCloak())
	end)
end

M:RegisterMiscModule("HatTrick", LoadFunc)